<template>
	<view class="container">
		<view class="NavBarBox">
			<view class="navbar">
				<view class="navItem" :class="current == 0 ? 'active':''" @click="checkItem(0)">查询成功</view>
				<view class="navItem" :class="current == 1 ? 'active':''" @click="checkItem(1)">查询失败</view>
			</view>
			<view class="Num" @click="topage">次数购买记录</view>
		</view>
		
		<view class="List">
			<orderItem v-for="(item,index) in list" :key="index" :OBJ="item"></orderItem>
		</view>
</view>
</template>

<script>
import { QueryHistorySuccessfulOrders, QueryReportRecord } from '../../API/api';
	export default {
		data() {
			return {
				current:0,
				list:[]
			};
		},
		onLoad() {
			this.getList()
		},
		computed:{
			
		},
		methods:{
			topage(){
				uni.navigateTo({
					url:'/pages/frequency/frequency'
				})
			},
			checkItem(value){
				this.current = value
				if(this.current == 0){
					QueryReportRecord({status:this.current}).then(res=>{
						this.list = res.data.filter(item => item.type == 1)
					}).catch(err=>{})
				}else if(this.current == 1){
					QueryReportRecord({status:this.current}).then(res=>{
						this.list = res.data.filter(item => item.type == 1)
					}).catch(err=>{})
				}
			},
			getList(){
				QueryReportRecord({status:0}).then(res=>{
					this.list = res.data.filter(item => item.type == 1)
				}).catch(err=>{})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		min-height: 100vh;
		.NavBarBox{
			display: flex;
			align-items: center;
			padding: 18rpx 30rpx;
			background-color: #fff;
			justify-content: space-between;
			.navbar{
				display: flex;
				align-items: center;
				background-color: #fff;
				.navItem{
					width: 128rpx;
					height: 52rpx;
					font-weight: 400;
					font-size: 28rpx;
					color: #999999;
					text-align: center;
					line-height: 52rpx;
					margin-right: 30rpx;
					background-color: #FFFFFF;
					border-radius: 26rpx 26rpx 26rpx 26rpx;
				}
				.active{
					color: #FFFFFF !important;
					background-color: #00A3E6 !important;
				}
			}
			.Num{
				font-weight: 400;
				font-size: 28rpx;
				color: #00A3E6;
			}
		}
		
		
		.List{
			padding: 36rpx;
		}
	}
</style>
